<template>
  <rx-layout style="padding: 10px">
    <template #middle>
      <rx-fit v-model="fitSearch">
        <template #head>
          <div style="display: flex;align-items: center;justify-content: space-between;">
            <rx-list-title :title="i18n('list.myAttachment','异步下载')"></rx-list-title>
            <span class="search-btn" @click.stop="searchshow" @mousedown.stop><SearchOutlined/>{{ $ti18('rxList.leachBtn', '过滤') }}</span>
          </div>
        </template>
        <template #search>
          <a-form layout="vertical">
            <a-form-item :label="i18n('form.fileName','文件名')">
              <a-input :placeholder="i18n('form.fileName','文件名','input')" v-model:value="urlConfig.queryParam.Q_FILE_NAME__S_LK"/>
            </a-form-item>
          </a-form>
          <div class="list-search-toolbar">
            <a-button type="primary" @click="search">
              <SearchOutlined/>
              {{ $ti18('rxList.searchBtn', '查询') }}
            </a-button>
            <a-button style="margin-left: 4px" @click="resetSearch">
              <RedoOutlined />
              {{ $ti18('rxList.resetBtn', '重置') }}
            </a-button>
          </div>
        </template>
        <template #middle>
          <rx-grid ref="table"
                   :hasPage="true"
                   :urlConfig="urlConfig"
                   :selectConfig="selectConfig"
                   url="/api-system/system/core/sysFile/mySysFile"
                   field="fileId"
                   :columns="columns"
          >
            <template #totalBytes="{row}">
              {{row.totalBytes | totalBytes}}
            </template>
          </rx-grid>
        </template>
      </rx-fit>
    </template>
  </rx-layout>
</template>

<script>
  import SysFileApi from '@/common/api/system/sysFile'
  import {BaseList,RxFit } from '@lowcode/jpaas-base-lib';
  export default {
    name: 'MySysFileList',
    mixins: [BaseList],
    components: {
      RxFit
    },
    data() {
      return {
        urlConfig: {
          ajaxType: 'post',
          contentType: 'json',
          queryParam: {},
          dataField: 'result.data',
          totalField: 'result.totalCount'
        },
        selectConfig: {
          type: 'checkbox',
        },
        columns: [
          {title: this.i18n('form.fileName','文件名'), field: 'fileName',minWidth:100},
          {title: this.i18n('form.ext','扩展名'), field: 'ext', minWidth: 100},
          {title: this.i18n('form.totalBytes','总字节数'), field: 'totalBytes', minWidth: 100, slots: { default: 'totalBytes' },},
          {title: this.i18n('form.uploadTime','上传时间'), field: 'createTime', minWidth: 200}
        ],
        comment:this.i18n('list.comment','系统文件'),
        widthHeight:['800px','600px'],
      }
    },
    methods:{
      i18n(name,text,key){
          return this.$ti18(name,text,"MySysFile",key);
      },
      delById(ids){
        return SysFileApi.del({ ids: ids.join(',') });
      },
      totalBytes(val){
        return (val/1024).toFixed(0) + "KB";
      }
    }
  }
</script>
<style scoped>

</style>

